struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) {
    if(headA == NULL || headB==NULL)

    {
        return NULL;
    }
    struct ListNode* curA=headA , *curB =headB; 

    int lenA =1,lenB=1;
    while(curA->next)
    {
        curA=curA->next;
        ++lenA;
    }
    while(curB->next)
    {
        curB=curB->next;
        ++lenB;
    }
    if(curA!=curB)
    {
        return NULL;
    }

    int gap=abs(lenA-lenB);
    struct ListNode *longList=headA,*shortList=headB;
    if(lenB>lenA)
    {
        longList = headB;
        shortList = headA;
    }
    while(gap--)
    {
        longList=longList -> next;
    } 
    while(longList != shortList)
    {
        longList=longList->next;
        shortList=shortList->next;
    }
    return shortList;


}